package top.greatxiaozou.utils;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import top.greatxiaozou.model.Result;

public class ResultsUtils {
    //通用的获取方法，成功和失败都来自于此
    public static ResponseEntity<Result> commenResult(Object data, Integer code,String msg,HttpStatus status){
        return new ResponseEntity<>(new Result<>(data,code,msg),status);
    }

    //成功
    public static ResponseEntity<Result> success(Object data,String msg,HttpStatus status){
        return commenResult(data,1,msg,status);
    }
    public static ResponseEntity<Result> success(Object data,String msg){
        return commenResult(data,1,msg,HttpStatus.OK);
    }

    //失败
    public static ResponseEntity<Result> faild(String msg,HttpStatus status){
        return commenResult(null,0,msg,status);
    }

}
